﻿<%@ Page Title="Admin" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Admin.aspx.cs" Inherits="WebApplication2.Admin" %>

<asp:Content runat="server" ID="FeaturedContent" ContentPlaceHolderID="FeaturedContent">
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">
                <h1><%: Title %>.</h1>
                <h2>Groep16 - Festivalinfo</h2>
            </hgroup>
            <p>
                Beheren van gebruikers en rollen.</p>
        </div>
    </section>
</asp:Content>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <p>&nbsp;</p>
    <div class="content-wrapper">
        <asp:ListView ID="ListView1" runat="server" DataKeyNames="RoleId" DataSourceID="SqlDataSource2" OnItemUpdating="ListView1_ItemUpdating" OnItemEditing="ListView1_ItemEditing" OnItemCanceling="ListView1_ItemCanceling" OnItemDeleting="ListView1_ItemDeleting">
            <AlternatingItemTemplate>
                <span style="">ApplicationId:
                <asp:Label ID="ApplicationIdLabel" runat="server" Text='<%# Eval("ApplicationId") %>' />
                <br />
                RoleId:
                <asp:Label ID="RoleIdLabel" runat="server" Text='<%# Eval("RoleId") %>' />
                <br />
                RoleName:
                <asp:Label ID="RoleNameLabel" runat="server" Text='<%# Eval("RoleName") %>' />
                <br />
                Description:
                <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                <br />
                <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<br /><br /></span>
            </AlternatingItemTemplate>
            <EditItemTemplate>
                <span style="">ApplicationId:
                <asp:TextBox ID="ApplicationIdTextBox" runat="server" Text='<%# Bind("ApplicationId") %>' />
                <br />
                RoleId:
                <asp:Label ID="RoleIdLabel1" runat="server" Text='<%# Eval("RoleId") %>' />
                <br />
                RoleName:
                <asp:TextBox ID="RoleNameTextBox" runat="server" Text='<%# Bind("RoleName") %>' />
                <br />
                Description:
                <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
                <br />
                <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
                <br /><br /></span>
            </EditItemTemplate>
            <EmptyDataTemplate>
                <span>No data was returned.</span>
            </EmptyDataTemplate>
            <InsertItemTemplate>
                <span style="">ApplicationId:
                <asp:TextBox ID="ApplicationIdTextBox" runat="server" Text='<%# Bind("ApplicationId") %>' />
                <br />RoleId:
                <asp:TextBox ID="RoleIdTextBox" runat="server" Text='<%# Bind("RoleId") %>' />
                <br />RoleName:
                <asp:TextBox ID="RoleNameTextBox" runat="server" Text='<%# Bind("RoleName") %>' />
                <br />Description:
                <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
                <br />
                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
                <br /><br /></span>
            </InsertItemTemplate>
            <ItemTemplate>
                <span style="">ApplicationId:
                <asp:Label ID="ApplicationIdLabel" runat="server" Text='<%# Eval("ApplicationId") %>' />
                <br />
                RoleId:
                <asp:Label ID="RoleIdLabel" runat="server" Text='<%# Eval("RoleId") %>' />
                <br />
                RoleName:
                <asp:Label ID="RoleNameLabel" runat="server" Text='<%# Eval("RoleName") %>' />
                <br />
                Description:
                <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                <br />
                <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<br /><br /></span>
            </ItemTemplate>
            <LayoutTemplate>
                <div id="itemPlaceholderContainer" runat="server" style="">
                    <span runat="server" id="itemPlaceholder" />
                </div>
                <div style="">
                </div>
            </LayoutTemplate>
            <SelectedItemTemplate>
                <span style="">ApplicationId:
                <asp:Label ID="ApplicationIdLabel" runat="server" Text='<%# Eval("ApplicationId") %>' />
                <br />
                RoleId:
                <asp:Label ID="RoleIdLabel" runat="server" Text='<%# Eval("RoleId") %>' />
                <br />
                RoleName:
                <asp:Label ID="RoleNameLabel" runat="server" Text='<%# Eval("RoleName") %>' />
                <br />
                Description:
                <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                <br />
                <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<br /><br /></span>
            </SelectedItemTemplate>
        </asp:ListView>
        <asp:GridView ID="userGrid" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" />
                <asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" />
                <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                <asp:BoundField DataField="RoleName" HeaderText="RoleName" SortExpression="RoleName" />
                <asp:CheckBoxField DataField="IsApproved" HeaderText="IsApproved" SortExpression="IsApproved" />
                <asp:CheckBoxField DataField="IsLockedOut" HeaderText="IsLockedOut" SortExpression="IsLockedOut" />

            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" DeleteCommand="DELETE FROM Roles WHERE (RoleId = @RoleId)" SelectCommand="SELECT Roles.* FROM Roles" UpdateCommand="UPDATE Roles SET RoleName = @RoleName, Description = @Description WHERE (RoleId = @RoleId)">
            <DeleteParameters>
                <asp:Parameter Name="RoleId" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="RoleName" />
                <asp:Parameter Name="Description" />
                <asp:Parameter Name="RoleId" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="SELECT Users.UserName, Memberships.Password, Memberships.Email, Roles.RoleName, Memberships.IsApproved, Memberships.IsLockedOut FROM Users INNER JOIN UsersInRoles ON Users.UserId = UsersInRoles.UserId INNER JOIN Roles ON UsersInRoles.RoleId = Roles.RoleId INNER JOIN Memberships ON Users.UserId = Memberships.UserId"></asp:SqlDataSource>
    </div>
</asp:Content>